import tkinter as tk
# 导入 filedialog 模块
from tkinter import filedialog, ttk

import pandas as pd


class ProgressBarWindow:

    def __init__(self, parent):
        self.parent = parent
        self.window_width = 500
        self.window_height = 400
        self.screen_width = self.parent.winfo_screenwidth()
        self.screen_height = self.parent.winfo_screenheight()
        self.x = (self.screen_width - self.window_width) // 2
        self.y = (self.screen_height - self.window_height) // 2
        self.currentWindow = None
        self.progress_bar = None



    def showWindow(self, title):
        self.currentWindow = tk.Toplevel(self.parent)
        self.currentWindow.title(title)
        self.currentWindow.geometry(f"{self.window_width}x{self.window_height}+{self.x}+{self.y}")
        self.currentWindow.transient(self.parent)
        # 设置新窗口获得焦点
        self.currentWindow.grab_set()
        # 将新窗口提升到最顶层
        self.currentWindow.lift()
        # 创建第一个框架，用于放置第一行的控件
        self.progress_bar = ttk.Progressbar(self.currentWindow, length=200, mode="indeterminate")
        self.progress_bar.pack()
        self.progress_bar["mode"] = "indeterminate"
        self.progress_bar.start()
        #self.parent.wait_window(self.currentWindow)
        print("showWindow")
    def closeWindow(self):
        print("closeWindow")
        self.progress_bar.stop()
        self.currentWindow.destroy()





